package jd.monitor.jbtrace;

import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.annotations.*;

@BTrace(unsafe = true)
public class BtraceScript {
	
	@OnMethod(clazz = "jd.monitor.jbtrace.Demo", location = @Location(value = Kind.LINE, line = -1) )
	public static void online(@ProbeClassName String pcn, @ProbeMethodName String pmn, int line) {
		print(Strings.strcat(pcn, "."));
		print(Strings.strcat(pmn, ":"));
		println(line);
	}
	
	/*@OnMethod(clazz = "jd.monitor.jbtrace.Demo", method = "sayHello", location = @Location(Kind.RETURN) )
	public static void defineclass(String in, @Return String out) {
		println("in " + str(in));
		println("out " + str(out));
		jstack();
		println("==========================");
	}*/
	
	/*@OnMethod(clazz = "jd.monitor.jbtrace.Demo", method = "sayHello", location = @Location(Kind.RETURN) )
	public static void traceExecute(@Self Demo demo) {
		String name = (String) get(field("jd.monitor.jbtrace.Demo", "name"), demo);
		println("name "+name);
		println("=================");
	}*/
	
//	@OnMethod(clazz = "/jd.monitor.jbtrace.*/", method = "/.*/", location = @Location(value = Kind.CALL, clazz = "/jd.monitor.jbtrace.*/", method = "/sayHello.*/") )
//	public static void traceExecute(@ProbeClassName String pcm, @ProbeMethodName String pmn,
//			@TargetInstance Object instance, @TargetMethodOrField String method) {
//		println("====== ");
//		println(strcat("ProbeClassName: ", pcm));
//		println(strcat("ProbeMethodName: ", pmn));
//		println(strcat("TargetInstance: ", str(classOf(instance))));
//		println(strcat("TargetMethodOrField : ", str(method)));
////		jstack();
//	}

}
